package com.xbongbong.saas.enums;/*/*/

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 工单阶段 节点分配抢单类型
 * @author 魏荣杰
 * @date 2019/4/12 15:51
 * @since v1.0
 * @version v1.0
 */
@Getter
public enum WorkOrderStageRobTypeEnum {
    /**
     *
     */
    USER(0,"enum.workOrderStageRobType.name.user","user"),


    SERVICE(1,"enum.workOrderStageRobType.name.service","service"),


    DEPARTMENT(2,"enum.workOrderStageRobType.name.department","department"),
    ;
    private Integer code;
    private String name;
    private String alias;

    WorkOrderStageRobTypeEnum(Integer code, String name, String alias) {
        this.code = code;
        this.name = name;
        this.alias = alias;
    }

    public static WorkOrderStageRobTypeEnum getByCode(Integer code) {
        for (WorkOrderStageRobTypeEnum cache : values()) {
            if (cache.getCode().equals(code)) {
                return cache;
            }
        }
        return null;
    }

    /**
     * 通过code获取名称
     * @param code
     * @return java.lang.String
     * @author zcp
     * @date 2019/7/11 9:28
     * @since v1.0
     * @version v1.0
     */
    public static String getNameByCode(Integer code) {
        for (WorkOrderStageRobTypeEnum cache : values()) {
            if (cache.getCode().equals(code)) {
                return cache.getName();
            }
        }
        return "";
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
